package Game;

import java.awt.Graphics2D;
import java.util.LinkedList;
import java.util.Random;

public class PeopleManager
{
	private static LinkedList<People> lPeople;
	
	private static int spawnDelay, spawnDelay2;
	private static float counter, counter2;
	
	private static Random r = new Random();
	
	private PeopleManager() {}
	
	public static void Setup()
	{
		lPeople = new LinkedList<People>();
		
		spawnDelay = 200;
		
		spawnDelay2 = 350;
		
		counter2 = spawnDelay2 * 0.5f;
		
		counter = spawnDelay * 0.5f;
	}
	
	public static void Add(People people)
	{
		lPeople.add(people);
	}
	
	public static void Remove(People people)
	{
		lPeople.remove(people);
	}
	
	public static void Update()
	{
		counter++;
		counter2++;
		
		if(counter >= spawnDelay)
		{
			Add(new PeopleComum(r.nextInt(550), r.nextInt(400)));
			counter = 0;
		}
		
		if(counter2 >= spawnDelay2)
		{
			Add(new PeoplePolitic(r.nextInt(550), r.nextInt(400)));
			counter2 = 0;
		}
		
		if(lPeople != null)
		{
			for(People people : lPeople)
			{
				people.Update();
			}
		}
	}
	
	public static void Draw(Graphics2D g2d)
	{
		if(lPeople != null)
		{
			for(People people : lPeople)
			{
				people.Draw(g2d);
			}
		}
	}
}